//
//  SourceListItem.h
//  PXSourceList
//
//  Created by Alex Rozanski on 08/01/2010.
//  Copyright 2010 Alex Rozanski http://perspx.com
//

//#import <Cocoa/Cocoa.h>

#import "PXTableObject.h"
#import "Data_Model.h"
#import "Data_Object.h"
@class treeNode; 


//標記：樹狀結構的各個資料統計 定義
#define TableCalcuate_sum @"TableCalcuate_sum"
#define TableCalcuate_Mesa_long_ratio @"TableCalcuate_Mesa_long_ratio"

@interface SourceListItem : NSObject<NSCoding> {
	
    //資料模型參考位置
    //Data_Model *datamodel_SLI;
    
    //標記:要增加點結構NODE的資料時，要增加的程式碼    
    
    //名稱與辨識碼
    NSString *title;
	NSString *identifier;
	
    //圖示
    NSString *icon;
	  
    //母物件
	SourceListItem *paraent;
    //子物件陣列
    NSMutableArray *children;
    
    //資料表的物件資料 參考 最主要是用來記錄個別資料物件的位置
    PXTableObject *tableobject; 
     
    //此物件是否只當做資料夾使用
    NSNumber *isUseForGroup;
    
    //統計資料
    NSString  *badgeValue;  
    
    //ios 表格相對應的結點
    treeNode *treeNode_self;
    
}

//標記:要增加點結構NODE的資料時，要增加的程式碼

@property (nonatomic, retain)   NSString  *badgeValue;
@property (nonatomic, copy)     NSString *title;
@property (nonatomic, copy)     NSString *identifier;
@property (nonatomic, copy)     NSNumber *isUseForGroup;
@property (nonatomic, retain)   NSString *icon;
@property (nonatomic, retain)   NSMutableArray *children;
@property (nonatomic, retain)   PXTableObject *tableobject;
@property (nonatomic, assign)   SourceListItem *paraent;
@property (nonatomic, retain)   treeNode *treeNode_self;

//快速初始化
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier;
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier icon:(NSString*)anIcon;

-(NSInteger)inexparent;
- (BOOL)hasBadge;
- (BOOL)hasChildren;
- (BOOL)hasParent;
- (BOOL)hasIcon;
- (void)addChid:(SourceListItem *)ch;

//取出涵蓋最上層所有的node 節點資料
- (SourceListItem *)get_TopParaent;

//取出涵蓋自己到最上層所有的node 節點資料
- (SourceListItem *)get_ALLParaent:(NSMutableArray *)all_parent;

//取的資料模型參考位置
//-(void)set_Data_model:(Data_Model *)dml;

//計算所有節點的統計值
-(void)update_TableCalcuate:(NSMutableDictionary *)sort_data;

 //將代碼陣列 加入整個dataarrayobject
-(void)set_arraycode_to_data_array_object:(NSMutableArray *)codearray set_Data_model:(Data_Model *)dml;


-(NSMutableArray *)get_allcode_from_data_array_object;

 
-(void)sort_TableObjet_Data_Object_Array:(NSMutableDictionary *)sort_field;
 
@end
